package t3;

import java.io.IOException;
import java.util.Scanner;

import t3bean.CarBean;
import t3bean.ParkingLotBean;

public class Client {
	static ParkingLotBean pl = new ParkingLotBean();
	static {
		try {
			pl = new Deserialization().deserialization();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws IOException {
		Scanner cin = new Scanner(System.in);
//		List<ParkingSpace> spaceList = new ArrayList<ParkingSpace>();
//		List<ChargeRecord> recordList = new ArrayList<ChargeRecord>();
//		for (int i = 0; i < 5; i++) {
//			AddParkingSpace aps = new AddParkingSpace();
//			spaceList = aps.addParkingSpace(i, spaceList);
//		}
//		pl.setcRList(recordList);
//		pl.setpSList(spaceList);
		String n = "6";
		while (true) {

			System.out.println("1停车");
			System.out.println("2开车");
			System.out.println("3查看停车位信息");
			System.out.println("4查看缴费信息");
			System.out.println("0退出");
			n = cin.nextLine();
			if (n.equals("1")) {
				System.out.println("输入车牌号");
				String licensePlate = cin.nextLine();
				System.out.println("输入高度");
				Integer height = Integer.parseInt(cin.nextLine());
				CarBean car = new CarBean(licensePlate, height);
				ParkingCar pc = new ParkingCar();
				pl = pc.parkingCar(pl, car);
			} else if (n.equals("2")) {
				ChargeCar cc = new ChargeCar();
				System.out.println("输入车牌号");
				String licensePlate = cin.nextLine();
				System.out.println("输入停车位号");
				Integer id = Integer.parseInt(cin.nextLine()) - 1;
				pl = cc.chargeCar(pl, licensePlate, id);
			} else if (n.equals("3")) {
				SelectAllParkingSpace saps = new SelectAllParkingSpace();
				saps.selectAllParkingSpace(pl);
			} else if (n.equals("4")) {
				SelectAllChargeRecord sacr = new SelectAllChargeRecord();
				sacr.selectAllChargeRecord(pl);
			} else if (n.equals("0")) {
				new Serialize().serialize(pl);
				break;
			}
		}
		cin.close();
	}
}
